#include<bits/stdc++.h>
using namespace std;
#define int long long

const int MOD = 1e9 + 7;

int a[100005];

signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> a[i];
	sort(a + 1, a + m + 1);
	a[m + 1] = n + 1;

	int t = 0;
	int cnt = 1, mx = 0;
	int flag = 0;
	for (int i = 1; i <= m + 1; i++) {
		t = a[i] - a[i - 1] - 1;

		if (t <= 1)	continue;

		flag = 1;

		cnt %= MOD;
		cnt *= t % 2 ? (t + 1) / 2 : 1;

		mx += t / 2;
	}
	if (!flag)
		cout << 0 << endl << 0;
	else
		cout << mx << endl << cnt % MOD;
	return 0;
}
